﻿import React from 'react'
import ReactDOM from 'react-dom'
import mirror, { actions, connect } from 'mirrorx'

import { IntlProvider, addLocaleData } from 'react-intl'

import intl from 'intl'
import zh from 'react-intl/locale-data/zh'
import en from 'react-intl/locale-data/en'

import { LocaleProvider } from 'antd-mobile' // ant design mobile 只支持英文 中文
import enUS from 'antd-mobile/lib/locale-provider/en_US'

import Main from './main'
addLocaleData([...en, ...zh])

class App extends React.Component {
  constructor (props) {
    super(props)
  }

  componentDidMount () {

  }

  render () {
    const locale = navigator.language.split('-')[0]
    const lang = window.LangMessage
    let reactLocale = T.cookie.get('lang') == 'zh_TW' ? null : enUS
    reactLocale = T.cookie.get('lang') == 'en_US' ? enUS : reactLocale

    return (<div>
      <IntlProvider locale={locale} messages={lang}>
        <LocaleProvider locale={reactLocale}>
          <Main />
        </LocaleProvider>
      </IntlProvider>
    </div>
    )
  }
}

export default App
